package com.cntaiping.workutil.prometheus;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;


@Configuration
@EnableAsync
public class ScheduleConfig implements SchedulingConfigurer {

    private static final Logger logger = LoggerFactory.getLogger(ScheduleConfig.class);


    /**
     * 默认的多个任务之间会阻塞
     * 配置之后单个任务会阻塞，单个未执行完，后续任务不会执行
     */
    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(20));
    }
}
